package com.gec.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gec.model.system.ITripArea;
import com.gec.model.system.ITripCity;
import com.gec.model.system.ITripSights;
import com.gec.model.vo.ITripCityQueryVo;
import com.gec.system.mapper.ITripCityMapper;
import com.gec.system.service.ITripCityService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author chenzhiling
 * @since 2024-01-22
 */
@Service
public class ITripCityServiceImpl extends ServiceImpl<ITripCityMapper, ITripCity> implements ITripCityService {

    @Override
    public IPage<ITripCity> selectPage(IPage<ITripCity> page1, ITripCityQueryVo iTripCityQueryVo) {
        IPage<ITripCity> iPage = this.baseMapper.selectPage(page1, iTripCityQueryVo, null);
        return iPage;
    }

    @Override
    public ITripCity selectByName(String cityName) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("cityName",cityName);//相当于where name=1
        List<ITripCity> list = baseMapper.selectList(wrapper);
        return list.size()==0 ?null :list.get(0);
    }

    @Override
    public List<ITripCity> selectByAreaId(Long areaId) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("areaId",areaId);//相当于where name=1
        List<ITripCity> list = baseMapper.selectList(wrapper);
        return list.size()==0 ?null :list;
    }
}
